import {request} from "../../request/index.js"
Page({
  data:{
    myForum:[],
    forumname:''
  },
  onLoad(){
    let that = this;
    // 获取本地存储的用户昵称
    wx.getStorage({
      key: 'nickName',
      success: function(res){
        that.setData({
          forumname:res.data
        })
      }
    });
    // 调用getMyForum 得到信息
    setTimeout(function(){that.getMyForum();},100)
    
  },
  async getMyForum(){
    let forumname = this.data.forumname;
    const myForum = await request({url:"/showMyForum",method:'post',data:{forumname}});
    console.log(myForum);
    this.setData({
      myForum:myForum.data.result
    })
  },
  async handleDelete(e){
    
    const forumname = e.currentTarget.dataset.id.forumname;
    const forumcon =  e.currentTarget.dataset.id.forumcon;
    // console.log(forumname);
    const params = {forumname,forumcon}
    // 发请求 将关注的用户存入interest关注表
    const deleteForum = await request({url:"/deleteForum",method:'post',data:params});
    console.log(deleteForum);
    // 删除成功后 再次获取个人发布内容 展示
    this.getMyForum();
    
  },
 async onShow(){
  this.getMyForum();
 }
})